package com.letv.whatslive.model.dto;

import com.letv.whatslive.common.string.StringUtils;
import com.letv.whatslive.model.WeidianItem;
import com.letv.whatslive.model.WeidianUserItems;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * Created by lbl on 2016/9/20.
 */
@Getter
@Setter
public class WeidianUserItemsDto {
    //    private Long userId;
    private String itemid;

    private String item_desc; //商品描述
    private String item_name; //商品名称

    private List<String> thumb_imgs; //商品缩略图
    private int stock; //库存量
    private String price; //价格

    private String url;


    public static WeidianUserItemsDto parseWeidianUserItemsDto(WeidianUserItems weidianUserItems, WeidianItem  weidianItem){
        WeidianUserItemsDto weidianUserItemsDto = new WeidianUserItemsDto();
//        weidianUserItemsDto.setUserId(weidianUserItems.getUserId());
        weidianUserItemsDto.setItem_desc(weidianItem.getItem_desc());
        weidianUserItemsDto.setItem_name(weidianItem.getItem_name());
        weidianUserItemsDto.setItemid(weidianItem.getItemid());
        weidianUserItemsDto.setPrice(StringUtils.formatDoubleWith2DecimalDigit(weidianItem.getPrice()));
        weidianUserItemsDto.setStock(weidianItem.getStock());
        weidianUserItemsDto.setThumb_imgs(weidianItem.getThumb_imgs());
        weidianUserItemsDto.setUrl("https://weidian.com/item.html?itemID=" + weidianItem.getItemid());

        return weidianUserItemsDto;
    }
}
